/*!
\copyright  Copyright (c) 2024 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file
\brief      Configuration for sensors accessed through sensor subsystem
*/

#if defined(INCLUDE_SENSOR_SUBSYSTEM)

#include "sensor_subsystem.h"   /* CAA Module */
#include "app_sensor.h"         /* ERPC Interfaces */

#include "app_task.h"
#include "headset_config.h"

#include <vm.h>
#include "headset_sensor.h"

#include "adk_log.h"

#include <message.h>
#include <vm.h>

bool HeadsetSensorLoadImage(Task init_task)
{
    const char test_image_name[] = appConfigSensorSsImageName();

    FILE_INDEX index = FileFind(FILE_ROOT, test_image_name, sizeof(test_image_name)-1);

    DEBUG_LOG_ALWAYS("HeadsetSensorLoadImage: find file - idx %d",index);

    if (index != FILE_NONE)
    {
        uint32 flags = 0;
        SensorSubsystem_LoadImage(init_task, index, flags);
        return TRUE;
    }
    else
    {
        Panic();
    }

    return FALSE;
}

bool HeadsetSensorConfigureSensor(Task init_task)
{
    UNUSED(init_task);

    DEBUG_LOG("HeadsetSensorConfigureSensor");

    SensorSubsystem_Register(appGetAppTask());

    if (VmGetResetSource() == RESET_SOURCE_PRODUCTION_TEST)
    {
        DEBUG_LOG_ALWAYS("HeadsetSensorConfigureSensor not starting ERPC");
        return TRUE;
    }
    return TRUE;
}

#endif /* INCLUDE_SENSOR_SUBSYSTEM*/
